package com.gd.transfer.nio;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

/**
 * @author du_tian_jie
 * @version v1.0
 * @date 2018/12/22 16:40
 * @desc:
 */
public class Myclient {

    public void initSocketChannel(){


    }

    public static void main(String[] args) {
        try {
            SocketChannel socketChannel = SocketChannel.open(new InetSocketAddress("localhost",36000));
//            非阻塞
            socketChannel.configureBlocking(false);
            ByteBuffer byteBuffer = ByteBuffer.allocate(1024);
            byteBuffer.put("测试001".getBytes());
//
            byteBuffer.flip();
            socketChannel.write(byteBuffer);
            byteBuffer.clear();
            socketChannel.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
